package org.dromara.germbank.controller;


import cn.dev33.satoken.annotation.SaCheckPermission;

import lombok.RequiredArgsConstructor;
import org.dromara.common.core.domain.R;
import org.dromara.common.log.annotation.Log;
import org.dromara.common.log.enums.BusinessType;
import org.dromara.common.mybatis.core.page.PageQuery;
import org.dromara.common.mybatis.core.page.TableDataInfo;
import org.dromara.common.web.core.BaseController;
import org.dromara.germbank.domain.bo.BusPartnerManagementBo;
import org.dromara.germbank.domain.vo.BusPartnerManagementVo;
import org.dromara.germbank.service.BusPartnerManagementService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;

/**
 * 管理团队管理
 *
 * @author congxing
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/management")
public class BusPartnerManagementController extends BaseController {

    private final BusPartnerManagementService busPartnerManagementService;

    /**
     * 查询管理团队管理列表
     */
    @SaCheckPermission("partners:management:list")
    @GetMapping("/list")
    public TableDataInfo<BusPartnerManagementVo> list(BusPartnerManagementBo bo, PageQuery pageQuery) {
        return busPartnerManagementService.queryPageList(bo,pageQuery);
    }

//    /**
//     * 新增partners:management:list
//     */
//    @SaCheckPermission("germbank:advertisement:add")
//    @Log(title = "广告管理", businessType = BusinessType.INSERT)
//    @PostMapping
//    public R<Void> add(@Validated @RequestBody BusPartnerManagementBo bo) {
//        if (!busPartnerManagementService.checkManagementNameUnique(bo)) {
//            return R.fail("新增广告'" + bo.getManagementName() + "'失败，广告名称已存在");
//        }
//        return toAjax(busPartnerManagementService.insertManagement(bo));
//    }

//    /**
//     * 修改保存广告
//     */
//    @SaCheckPermission("germbank:advertisement:edit")
//    @Log(title = "广告数据", businessType = BusinessType.UPDATE)
//    @PutMapping
//    public R<Void> edit(@Validated @RequestBody BusPartnerManagementBo bo) {
//        if (!busPartnerManagementService.checkManagementNameUnique(bo)) {
//            return R.fail("修改广告数据'" + bo.getManagementName() + "'失败，广告已存在");
//        }
//        busPartnerManagementService.updateManagementData(bo);
//        return R.ok();
//    }

    /**
     * 删除广告类型
     *
     * @param managementCodes      * 删除广告类型code串
     */
    @SaCheckPermission("germbank:advertisement:remove")
    @Log(title = "广告", businessType = BusinessType.DELETE)
    @DeleteMapping("/{managementCodes}")
    public R<Void> remove(@PathVariable Long[] managementCodes) {
        busPartnerManagementService.deleteManagementCodesDataByIds(Arrays.asList(managementCodes));
        return R.ok();
    }

}
